//
//  RegisterTableViewCell.m
//  PYWGetColor
//
//  Created by ENERGY on 2018/6/4.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "RegisterTableViewCell.h"

@interface RegisterTableViewCell()
@property (nonatomic, strong)UIImageView * headImg;//cell前的图片
@property (nonatomic, strong)UIView * lineView;//分割线
@end
@implementation RegisterTableViewCell
- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.contentTextFidle.placeholder = model[@"placeHolder"];
    self.headImg.image = [UIImage imageNamed:model[@"img"]];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        
        [self.contentView addSubview:self.headImg];
        [self.contentView addSubview:self.contentTextFidle];
        [self.contentView addSubview:self.lineView];
        __weak typeof (self)weakSelf = self;
        [self.headImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakSelf.mas_centerY);
            make.left.equalTo(weakSelf.mas_left).mas_offset(20 / WIDTH_6S_SCALE);
            make.width.mas_offset(15 / WIDTH_6S_SCALE);
            make.height.mas_offset(19 / HEIGHT_6S_SCALE);
        }];
        [self.contentTextFidle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.headImg.mas_right).mas_offset(15/WIDTH_5S_SCALE);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-15/WIDTH_5S_SCALE);
            make.top.bottom.equalTo(weakSelf.contentView);
        }];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(weakSelf.contentView.mas_bottom);
            make.height.mas_offset(1/WIDTH_5S_SCALE);
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(41/WIDTH_5S_SCALE);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-15/WIDTH_5S_SCALE);
        }];
        
    }return self;
}

- (UIImageView *)headImg{
    if (!_headImg) {
        _headImg = [[UIImageView alloc] init];
        _headImg.backgroundColor = [UIColor clearColor];
        [_headImg sizeToFit];
    }return _headImg;
}

- (UITextField *)contentTextFidle{
    if (!_contentTextFidle) {
        _contentTextFidle = [[UITextField alloc] init];
        _contentTextFidle.backgroundColor = [UIColor clearColor];
        [_contentTextFidle addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingDidEnd];
        _contentTextFidle.font = DEF_FontSize_14;
        _contentTextFidle.secureTextEntry = YES;
    }return _contentTextFidle;
}

- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(@"e9e9e9");
    }return _lineView;
}
-(void)textFieldDidChange:(UITextField *)textField{
    if (self.getTextFieldChangeBlock) {
        self.getTextFieldChangeBlock(textField.text);
    }
}
@end
